package com.example.pei.ithinklearnt.adapter;

import android.content.Context;
import android.view.View;

import com.example.pei.ithinklearnt.AppApplication;
import com.example.pei.ithinklearnt.R;
import com.example.pei.ithinklearnt.adapter.base.BaseRecyclerAdapter;
import com.example.pei.ithinklearnt.adapter.base.BaseRecyclerHolder;
import com.example.pei.ithinklearnt.bean.UserInfo;
import com.example.pei.ithinklearnt.view.base.IMutlipleItem;

import java.util.ArrayList;
import java.util.Collection;

/**
 * Created by Pei on 2018/5/14.
 */

public class NearbyPeopleAdapter extends BaseRecyclerAdapter<UserInfo> {

    private UserInfo currentUser= AppApplication.getCurrentUser();
    public NearbyPeopleAdapter(Context context, IMutlipleItem<UserInfo> items, Collection<UserInfo> datas) {
        super(context,items,datas);
    }

    @Override
    public void bindView(BaseRecyclerHolder holder, UserInfo item, int position) {
        //设置昵称
        holder.setText(R.id.tv_nickname,item.getNickName());
        //设置头像
        holder.setImageView(item.getHeadFileUrl(), R.drawable.default_head, R.id.img_roudhead);
        //设置性别
        if(item.getSex()!=null&&item.getSex()==1){
            holder.setImageResource(R.id.iv_sex,R.drawable.male );
        }else{
            holder.setImageResource(R.id.iv_sex,R.drawable.female);
        }
        //设置距离
        int meter=(int)(currentUser.getGpsLocate().distanceInKilometersTo(item.getGpsLocate())*1000); //m
        holder.setText(R.id.tv_distance,"大约距离"+(meter+1)+"米");

    }


}
